package com.eastfair.auth.api;

import com.eastfair.auth.dto.OrganizationDTO;
import com.eastfair.auth.dto.OrganizationRoleDto;
import com.eastfair.auth.dto.UserAccountDto;
import com.eastfair.auth.dto.UserOrganizationDTO;
import com.eastfair.auth.entity.Organization;
import com.eastfair.auth.entity.UserAccount;
import com.eastfair.auth.entity.UserOrganization;
import com.eastfair.auth.hystrix.AuthApiFallback;
import com.eastfair.auth.hystrix.UserAccountApiFallback;
import com.eastfair.auth.vo.ResourceOrganizationVo;
import com.eastfair.auth.vo.UserAccountVo;
import com.eastfair.core.base.R;
import com.eastfair.core.context.ContextUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * auth feign接口
 *
 * @Author ligang
 * @Date 2021/7/16 16:41
 */
@FeignClient(name = "auth/userAccount", fallback = UserAccountApiFallback.class)
public interface UserAccountServiceFeign {

    /**
     * 获取用户账户
     *
     * @param userId 用户id
     * @return
     */
    @GetMapping("/getById")
    R<UserAccount> get(@RequestParam("userId") Long userId);


    /**
     * 批量查询用户简单信息
     *
     * @param userAccountDto userIds 账户用户id集合
     * @return
     */
    @PostMapping("/querySimpleByIds")
    R<List<UserAccountVo>> querySimpleByIds(@RequestBody UserAccountDto userAccountDto);


    /**
     * 给其他项目创建管理员
     *
     * @param userAccountDto 用户新增实体
     * @return
     */
    @ApiOperation(value = "给其他项目创建管理员", notes = "给其他项目创建管理员")
    @PostMapping("/addAdminUser")
    R<UserAccountVo> addAdminUser(@RequestBody UserAccountDto userAccountDto);

    /**
     * 根据邮箱和手机号查询用户信息
     *
     * @param mobile 用户id
     * @param email  手机号
     * @return
     */
    @ApiOperation(value = "根据邮箱和手机号查询用户信息", notes = "根据邮箱和手机号查询用户信息")
    @GetMapping("/queryOfPhoneOrEmail")
    R<UserAccount> queryOfPhoneOrEmail(@RequestParam("mobile") String mobile, @RequestParam("email") String email);


    @ApiOperation(value = "注册", notes = "注册")
    @PostMapping("/register")
    R<UserAccountVo> register(@RequestBody UserAccountDto userAccountDto);


    @ApiOperation(value = "根据邮箱和手机号查询用户信息", notes = "根据邮箱和手机号查询用户信息")
    @GetMapping("/test")
    R<String> test();


    /**
     * 成为展商，观众
     *
     * @param userAccountDto
     * @return
     */
    @ApiOperation(value = "成为展商，观众", notes = "成为展商，观众")
    @PostMapping("/initRole")
    R<UserAccountVo> initRole(@RequestBody UserAccountDto userAccountDto);

    /**
     * 检验是否有权限
     *
     * @param userId
     * @param permission
     * @return
     */
    @ApiOperation(value = "检验是否有权限", notes = "检验是否有权限")
    @GetMapping("/isPermission")
    R<Boolean> isPermission(@RequestParam("userId") Long userId, @RequestParam("permission") String[] permission);


    /**
     * 修改关联信息（观众id，展商id，公司id）
     *
     * @param userAccountDto
     * @return
     */
    @ApiOperation(value = "修改关联信息", notes = "修改关联信息")
    @PostMapping("/updateCorrelationById")
    R<Boolean> updateCorrelationById(@RequestBody UserAccountDto userAccountDto);


    /**
     * 添加公司用户
     *
     * @param userAccountDto 用户新增实体
     * @return
     */
    @ApiOperation(value = "添加公司用户", notes = "添加公司用户")
    @PostMapping("/saveCompanyUser")
    R<UserAccountVo> saveCompanyUser(@RequestBody UserAccountDto userAccountDto);


    /**
     * 修改用户信息
     *
     * @param userAccountDto
     * @return
     */
    @ApiOperation(value = "修改用户信息", notes = "修改用户信息")
    @PutMapping("/updateById")
    R<Boolean> updateById(@RequestBody UserAccountDto userAccountDto);

}
